<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.controller;</#if>
<#if isAutoImport?exists && isAutoImport==true>
import com.metareco.common.vo.ApiResponse;
import org.audit4j.core.annotation.Audit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

</#if>
@RestController
@RequestMapping("/api/${classInfo.className?uncap_first}")
@Audit
public class ${classInfo.className}RestApi {
    @Autowired
    private ${classInfo.className}Service ${classInfo.className?uncap_first}Service;

    @GetMapping("/list")
    public ApiResponse<Page<${classInfo.className}DTO>> list(Integer id, String keyword, @RequestParam(required = false, defaultValue = "0") int page,
        @RequestParam(required = false, defaultValue = "10") int size,
        @RequestParam(required = false, defaultValue = "id") String sortField, @RequestParam(defaultValue = "DESC") Sort.Direction sortDirection) {
        return ApiResponse.success(${classInfo.className?uncap_first}Service.list(id, keyword, page, size, sortField, sortDirection));
    }

    @GetMapping("/export")
    public ApiResponse<Map<String, Object>> export(Integer id, String keyword, @RequestParam(required = false, defaultValue = "0") int page,
        @RequestParam(required = false, defaultValue = "9999999") int size,
        @RequestParam(required = false, defaultValue = "id") String sortField, @RequestParam(defaultValue = "DESC") Sort.Direction sortDirection) {
        return ApiResponse.success(${classInfo.className?uncap_first}Service.export(id, keyword, page, size, sortField, sortDirection));
    }

    @PostMapping("/update")
    public ApiResponse<Void> update(@RequestBody ${classInfo.className}DTO ${classInfo.className?uncap_first}) {
        ${classInfo.className?uncap_first}Service.update(${classInfo.className?uncap_first});
        return ApiResponse.SUCCESS;
    }

    @DeleteMapping("/delete")
    public ApiResponse<Void> delete(int id) {
        ${classInfo.className?uncap_first}Service.delete(id);
        return ApiResponse.SUCCESS;
    }
}

